package ch6.ex1;

import static ch6.print.Print.*;

class Engine {
	private String s;
	
	Engine(){
		println("Engine()");
		s = "Constructed";
	}
	
	public String toString(){
		return s;
	}
}

public class Airplane {
	
	private String fuselage, wings, tail;
	private Engine e = new Engine();
	
	public Airplane(){
		println("Inside Airplane()");
		fuselage = "Body";
		wings = "Airfoils";
		tail = "Empennage";
	}
	
	public String toString(){
		if(e == null){
			e = new Engine();
		}
		else{
			println("Engine object already exists.");
		}
		return "fuselage = " + fuselage + ", " +
			   "wings = " + wings + ", " +
			   "tail = " + tail + ", " + 
			   "Engine = " + e;
	}
	public static void main(String... args){
		Airplane ai = new Airplane();
		print(ai);
	}
}
